<?php
namespace Home\Controller;
use Think\Controller;
class RegisterController extends CommonController {
    public function register(){
        $this->display();
    }
    public function add(){
		$email = I ('get.email');
		$password = I ('get.password');
		
		$passwordRepeat = I ('get.passwordRepeat');
		if( $email == false){
				$this->error("邮箱不能为空");
			}
	    $User = D("User"); 
		$res = $User->where("user_nickname='{$email}'")->find();
		if( $res == true ){
			$this->response(false, 0, '该邮箱已注册');
		}
		if( $password == $passwordRepeat && $password != '' && $passwordRepeat != ''){
			$data = array(
				'user_nickname' => $email,
				'password' => $password,
				//'head_img' => '',
				'addtime'  =>time()
			);
			$ret =$User->add($data);
		}
		if( $ret == false ){
				$this->response(false, 0, $ret);
		}else{
				$this->response(true, 1, $data['user_nickname']);
			}
			
	}
}
